
<!DOCTYPE html>
<html>
<head>
  <title>找回/重置密码 - 麻雀博客</title>
  <#include "../common/link.ftl">
</head>
<body>

<#include "../common/header.ftl">

<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li><a href="${ctx.contextPath}/user/login">登入</a></li>
        <li class="layui-this">找回密码<!--重置密码--></li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <div class="layui-form layui-form-pane">
            <#--<form method="post">-->
              <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" id="email" name="email" value="" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">若在收件箱找不到邮件，请查看垃圾箱，并设置‘这不是垃圾邮件’</div>
              </div>
              <div class="layui-form-item">
                <label for="L_vercode" class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                  <input type="text" id="imagecode" name="vercode" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">
                    <img class="pointer" id="img_label" height="38" src="${ctx.contextPath}/code/captcha.jpg" alt="点击刷新"/>
                </div>
              </div>
              <div class="layui-form-item">
                <button class="layui-btn" alert="1" lay-filter="*" id="forget_btn">提交</button>
              </div>
            <#--</form>-->
          </div>
          
        </div>
      </div>
    </div>
  </div>

  
</div>

<#include "../common/footer.ftl">
<script type="text/javascript">
    $('#img_label').on('click', function(){
        $("#img_label").attr("src" ,"${ctx.contextPath}/code/captcha.jpg?t=" + $.now());
    });

    $("#forget_btn").on("click", function () {
        var email_input = $("#email");
        var imagecode_input = $("#imagecode");
        if (!check_email(email_input) || !check_val(imagecode_input)) {
            return;
        }
        //添加遮罩层
        var load = layer.load();
        $.ajax({
            url: "${ctx.contextPath}/user/reset_pass",
            type: "post",
            data: {email:email_input.val(), imagecode: imagecode_input.val()},
            dataType: "json",
            success: function (result) {
                layer.close(load);//关闭遮罩层
                if (result.status == 0) {
                    error_msg(result.msg)
                } else {
                    success_msg(result.msg)
                }
                imagecode_input.val("");
            }
        });
    });
</script>
</body>
</html>